package com.eschool.config;

import com.eschool.controller.home.IndexController;
import com.eschool.controller.home.RegistController;
import com.eschool.controller.home.TeamController;
import com.eschool.controller.home.UserController;
import com.eschool.interceptor.GlobleInterceptor;
import com.eschool.model.User;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;

public class AppConfig extends JFinalConfig {
	public void configConstant(Constants me) {
		me.setDevMode(true);
		me.setViewType(ViewType.FREE_MARKER);
	}

	public void configRoute(Routes me) {
		me.add("/index", IndexController.class);
		me.add("/team", TeamController.class);
		me.add("/user", UserController.class);
		me.add("/regist", RegistController.class);
	}

	public void configPlugin(Plugins me) {
		C3p0Plugin cp = new C3p0Plugin("jdbc:mysql://localhost/eschool", "root", "");
		me.add(cp);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);
		me.add(arp);
		arp.addMapping("user", User.class);
	}

	public void configInterceptor(Interceptors me) {
		me.add(new GlobleInterceptor());
	}

	public void configHandler(Handlers me) {
	}
}